<?php

/**
 * Created by PhpStorm.
 * User: dumbledore
 * Date: 2018/3/19
 * Time: 下午1:53
 */
class Upload extends CI_Controller
{

    public function __construct(){
        parent::__construct();
        $this->load->database();
        $this->load->library('form_validation');//加载表单验证类库
        $this->load->helper('json');
        $this->load->helper('common');
        $this->load->model('upload_model');
        $this->load->library('session');
    }

    // 上传图片
    public function upload_image()
    {
        $max_size = $this->config->item("max_image_size");
        $path = $this->config->item("upload_path");

        $data = $this->upload_model->do_upload('file',$path,true,true,$max_size);
        if($data['status'] == 0)
        {
            send_json(array('code'=>0,'data'=>['file_name'=>$data['data']['upload_data']['file_name']],'msg'=>"上传成功"));
        }else{
            send_json(array('code'=>-1,'data'=>$data['data'],'msg'=>"上传失败"));
        }

    }


}